import React from 'react'
import { Table, Dropdown, Button, Menu, Icon, Modal, Input, Select } from 'antd'
import { TweenOneGroup } from 'rc-tween-one'
import {dateFormat} from '../../utils'

const confirm = Modal.confirm;
const Option = Select.Option;

class list extends React.Component {
	constructor(props) {
		super(props);
		const { current } = this.props.pagination;
		this.currentPage = current;
		this.newPage = current;
		this.tableRowCheckedArr = [];
		this.querySate = "";
		this.queryExpireTime = "";
	}

  handleMenuClick = (record, e) => {
    const {onEditItem} = this.props
    onEditItem(record)
  }

	onEnd = (e) => {
		e.target.style.height = 'auto'
	};

	async pageChange(pagination) {
		await this.props.onPageChange(pagination);
		this.newPage = pagination.current
	}
	
	
	render() {
		const { loading, dataSource, pagination, onPageChange } = this.props;		
		const columns = [{
				title: '序号',
				dataIndex: 'idx',
				key: 'idx',
				render(text, record, index) {
						return (<span>{index+1}</span>)
				}
			},
			{
				title: '取件人',
				dataIndex: 'outman',
				key: 'outman',
			}, {
				title: '取件电话',
				dataIndex: 'phone',
				key: 'phone',
			}, {
				title: '下单时间',
				dataIndex: 'order_time',
				key: 'order_time',
				render(text, record, index) {
						let str=dateFormat(parseInt(text + '000'),'yyyy/MM/dd  hh:mm:ss')
						return (<span>{str}</span>)
				}
			}, {
				title: '取件时间',
				dataIndex: 'out_time',
				key: 'out_time',
				render(text, record, index) {
						let str=dateFormat(parseInt(text + '000'),'yyyy/MM/dd  hh:mm:ss')
						return (<span>{str}</span>)
				}
			}, {
				title: '订单编号',
				dataIndex: 'order_no',
				key: 'order_no',
				
			}, {
				title: '类型',
				dataIndex: 'type',
				key: 'type',
				render(text, record, index) {
					let str= text == '0' ? '普通' : '换货'	
					return (<span>{str}</span>)
				}
			}, {
				title: '操作',
				dataIndex: 'opeartion',
				key: 'opeartion',
				render: (text, record) => {
					return(
						<Button onClick={this.handleMenuClick.bind(null, record)}>进行换货</Button>
					)
				}
			}
		];
	
		return(
			<div style={{marginTop:10}}>
	    	<Table  columns={columns} dataSource={dataSource} loading={loading} onChange={onPageChange} pagination={pagination} />
	    </div>
		)
	}
}

export default list